﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Castle.Core.Interceptor;
using NUnit.Framework;
using Castle.DynamicProxy;

namespace JackyCode.Mock.Test.Spike
{
    [TestFixture]
    public class TestInterceptor
    {
        [Test]
        public void TestOutParameter()
        {
           IFoo foo = new ProxyGenerator().CreateInterfaceProxyWithoutTarget<IFoo>(new Interceptor());
            string result;
            foo.TryParse("hello", out result);
            Assert.AreEqual("hello", result);
        }
    }

    public interface IFoo
    {
        void TryParse(string input, out string output);
    }

    public class Interceptor : IInterceptor
    {
        public void Intercept(IInvocation invocation)
        {
            invocation.Arguments[1] = "HelloWorld";
        }
    }

}
